"""
@Project: pythonPro1
@Name: os1.py
@Author: linxin_liu
@Date: 2022/9/24 16:26
os模块提供了非常丰富的方法用来处理文件和目录。
"""
import os

path = 'F:/python_data'  # 所有需要操作的文件根目录

file1 = open(path+'/access1.txt', 'r')
print(file1.read())
file1.close()

# 检验权限模式
result = os.access(path+'/access1.txt', os.F_OK)
print('路径是否存在:{}'.format(result))
result = os.access(path+'/access1.txt', os.R_OK)
print('路径是否可读:{}'.format(result))
result = os.access(path+'/access1.txt', os.W_OK)
print('路径是否可写:{}'.format(result))
result = os.access(path+'/access1.txt', os.X_OK)
print('路径是否可操作:{}'.format(result))

print('绝对路径：', os.path.abspath(path+'/access1.txt'))
